package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TLeader;
import com.ruoyi.system.service.ITLeaderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重大重点项目负责人Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/leader")
public class TLeaderController extends BaseController
{
    @Autowired
    private ITLeaderService tLeaderService;

    /**
     * 查询重大重点项目负责人列表
     */
    @PreAuthorize("@ss.hasPermi('system:leader:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLeader tLeader)
    {
        startPage();
        List<TLeader> list = tLeaderService.selectTLeaderList(tLeader);
        return getDataTable(list);
    }

    /**
     * 导出重大重点项目负责人列表
     */
    @PreAuthorize("@ss.hasPermi('system:leader:export')")
    @Log(title = "重大重点项目负责人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLeader tLeader)
    {
        List<TLeader> list = tLeaderService.selectTLeaderList(tLeader);
        ExcelUtil<TLeader> util = new ExcelUtil<TLeader>(TLeader.class);
        util.exportExcel(response, list, "重大重点项目负责人数据");
    }

    /**
     * 获取重大重点项目负责人详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:leader:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tLeaderService.selectTLeaderById(id));
    }

    /**
     * 新增重大重点项目负责人
     */
    @PreAuthorize("@ss.hasPermi('system:leader:add')")
    @Log(title = "重大重点项目负责人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLeader tLeader)
    {
        return toAjax(tLeaderService.insertTLeader(tLeader));
    }

    /**
     * 修改重大重点项目负责人
     */
    @PreAuthorize("@ss.hasPermi('system:leader:edit')")
    @Log(title = "重大重点项目负责人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLeader tLeader)
    {
        return toAjax(tLeaderService.updateTLeader(tLeader));
    }

    /**
     * 删除重大重点项目负责人
     */
    @PreAuthorize("@ss.hasPermi('system:leader:remove')")
    @Log(title = "重大重点项目负责人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tLeaderService.deleteTLeaderByIds(ids));
    }
}
